﻿// 参数设置

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AdjPlane;

namespace PlaneADJ
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            this.Location = new Point(400, 200);
            textBox4.Enabled = false;
        }

        Weight WgtDef;
        public int Iter_n_vce = 20;
        public double Eps_vce = 1e-2;
        public double Eps_x = 1e-1;
        public int DisWgt = 1;
        int UseGyro = 0;
        int GyInAdp = 0;
        int GyOuAdp = 1;
        

        void Para()
        {
            Form2 child = new Form2();
            Eps_x = child.Eps_x;
            Iter_n_vce = child.Iter_n_vce;
            Eps_vce = child.Eps_vce;
            DisWgt = child.DisWgt;
            child.Close();
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
                DisWgt = 1;
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton2.Checked == true)
                DisWgt = 2;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            try
            {
                Iter_n_vce = Convert.ToInt32(textBox1.Text.Trim());
            }
            catch { }
        }


        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            try
            {
                Eps_vce = Convert.ToDouble(textBox2.Text.Trim());
            }
            catch { }
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            try
            {
                Eps_x = Convert.ToDouble(textBox3.Text.Trim());
            }
            catch { }
        }

        private void groupBox4_Enter(object sender, EventArgs e)
        {

        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true)
            {
                UseGyro = 1;
                textBox4.Enabled = true;
            }
            else
            {
                UseGyro = 0;
                textBox4.Enabled = false;
            }
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox2.Checked == true)
                GyInAdp = 1;
            else
                GyInAdp = 0;
        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {
            try
            {
                GyOuAdp = Convert.ToInt32(textBox4.Text.Trim());
            }
            catch { }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (comboBox1.Text.Contains("HVCE"))
                { WgtDef = Weight.Helmert; }
                else if (comboBox1.Text.Contains("SimplifyH1"))
                { WgtDef = Weight.hmt1; }
                else if (comboBox1.Text.Contains("SimplifyH2"))
                { WgtDef = Weight.hmt2; }
                else if (comboBox1.Text.Contains("SimplifyH3"))
                { WgtDef = Weight.hmt3; }
                else if (comboBox1.Text.Contains("MINQUE"))
                { WgtDef = Weight.MINQUE; }
                else if (comboBox1.Text.Contains("LSVCE"))
                { WgtDef = Weight.LSVCE; }
                else if (comboBox1.Text.Contains("MLE"))
                { WgtDef = Weight.MLE; }
            }
            catch { }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form1.popt_.Eps_X = Eps_x;
            Form1.popt_.Eps_VCE = Eps_vce;
            Form1.popt_.IterMax_VCE = Iter_n_vce;
            Form1.popt_.WgtDef = WgtDef;
            Form1.popt_.DisWgt = DisWgt;
            Form1.popt_.GyOpt.UseGyro = UseGyro;
            Form1.popt_.GyOpt.GyInAdp = GyInAdp;
            Form1.popt_.GyOpt.GyOuAdp = GyOuAdp;
            this.Visible = false;
        }
    }
}
